﻿<%@ Page Language="C#" MasterPageFile="~/Main.Master" AutoEventWireup="true" CodeBehind="ViewUser.aspx.cs"
    Inherits="ContractManagementSystem.ViewUser" Title="Contract Management System - View User" %>

<asp:Content ID="Content1" ContentPlaceHolderID="PanelContent" runat="server">

    <script type="text/javascript">
        function confirmPost()
        {
        	var agree = confirm("Are you sure you want to delete?");
        	if (agree)
        		return true;
        	else
        		return false;
        }
    </script>

    <div class="divWrap">
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <asp:Panel runat="server" ID="ViewPanel">
                    <h2 class="divTitle">
                        List User</h2>
                    <div class="divSearch">
                        <fieldset style="width: 98%; margin: auto; padding-left: 7px; padding-bottom: 10px;"
                            class="border">
                            <legend style="padding: 0px 5px 0px 5px; text-shadow: 3px 3px 3px #74907A; color: #045D97">
                                <b>Search</b></legend>
                            <table style="width: 100%">
                                <tr>
                                    <td>
                                        <asp:TextBox runat="server" ID="UserNameTextBox" AutoPostBack="True" OnTextChanged="UserNameTextBoxTextChanged"
                                            placeholder="Search username " ToolTip="Username"></asp:TextBox>
                                        <asp:Button runat="server" Text="Search" ToolTip="Search" />
                                    </td>
                                    <td style="text-align: right">
                                        View
                                        <asp:DropDownList runat="server" ID="StatusDropDownList" AutoPostBack="True" OnSelectedIndexChanged="StatusDropDownList_SelectedIndexChanged" />
                                    </td>
                                </tr>
                            </table>
                        </fieldset>
                    </div>
                    <asp:ListView ID="ContractListView" runat="server" ItemPlaceholderID="NewItem" OnSorting="ListSorting">
                        <LayoutTemplate>
                            <table id="table">
                                <tr>
                                    <th>
                                        <asp:LinkButton runat="server" ToolTip="Sort" CommandName="Sort" CommandArgument="RoleName"
                                            ID="LinkButton1">RoleName</asp:LinkButton>
                                        <asp:Image runat="server" ID="SortRole" CssClass="img" ImageUrl="App_Themes/Admin/Image/down.png" />
                                    </th>
                                    <th>
                                        <asp:LinkButton runat="server" ToolTip="Sort" CommandName="Sort" CommandArgument="UserName"
                                            ID="LinkButton2">UserName</asp:LinkButton>
                                        <asp:Image runat="server" ID="SortUserName" CssClass="img" ImageUrl="App_Themes/Admin/Image/down.png" />
                                    </th>
                                    <th>
                                        <asp:LinkButton runat="server" ToolTip="Sort" CommandName="Sort" CommandArgument="CreateDate"
                                            ID="LinkButton3">CreateDate</asp:LinkButton>
                                        <asp:Image runat="server" ID="SortCreateDate" CssClass="img" ImageUrl="App_Themes/Admin/Image/down.png" />
                                    </th>
                                    <th>
                                        Action
                                    </th>
                                </tr>
                                <tr>
                                    <asp:PlaceHolder runat="server" ID="NewItem"></asp:PlaceHolder>
                                </tr>
                            </table>
                        </LayoutTemplate>
                        <ItemTemplate>
                            <tr class="odd">
                                <td class="columnList">
                                    <asp:Label runat="server" ID="RoleNameLabel" Text='<%#Eval("RoleName")%>'></asp:Label>
                                    <asp:Label runat="server" ID="RoleNameId" Visible="False" Text='<%#Eval("RoleId")%>'></asp:Label>
                                </td>
                                <td class="columnList">
                                    <asp:Label runat="server" ID="UserNameLabel" Text='<%#Eval("UserName")%>'></asp:Label>
                                    <asp:Label runat="server" ID="UserIdLabel" Visible="False" Text='<%#Eval("UserId")%>'></asp:Label>
                                </td>
                                <td style="width: 120px">
                                    <asp:Label runat="server" ID="CreateDateLabel" Text='<%#Eval("CreateDate","{0:MM/dd/yyyy}")%>'></asp:Label>
                                    <asp:Label runat="server" ID="StatusLabel" Text='<%#Eval("IsActive")%>' Visible="false"></asp:Label>
                                </td>
                                <td style="width: 50px">
                                    <div style="text-align: center">
                                        <asp:LinkButton runat="server" ToolTip="Edit" ID="editLinkButton" CssClass="edit"
                                            CommandArgument='<%# DataBinder.Eval(Container.DataItem,"STT") %>' OnCommand="EditOnCommand">
                                        </asp:LinkButton>
                                        <asp:LinkButton runat="server" ToolTip="Delete" ID="deleteButton1" CssClass="delete"
                                            CommandArgument='<%# DataBinder.Eval(Container.DataItem,"UserId") %>' OnCommand="DeleteOnCommand"
                                            OnClientClick="return confirmPost()"></asp:LinkButton>
                                    </div>
                                </td>
                            </tr>
                        </ItemTemplate>
                        <AlternatingItemTemplate>
                            <tr class="alt">
                                <td class="columnList">
                                    <asp:Label runat="server" ID="RoleNameLabel" Text='<%#Eval("RoleName")%>'></asp:Label>
                                    <asp:Label runat="server" ID="RoleNameId" Visible="False" Text='<%#Eval("RoleId")%>'></asp:Label>
                                </td>
                                <td class="columnList">
                                    <asp:Label runat="server" ID="UserNameLabel" Text='<%#Eval("UserName")%>'></asp:Label>
                                    <asp:Label runat="server" ID="UserIdLabel" Visible="False" Text='<%#Eval("UserId")%>'></asp:Label>
                                </td>
                                <td>
                                    <asp:Label runat="server" ID="CreateDateLabel" Text='<%#Eval("CreateDate","{0:MM/dd/yyyy}")%>'></asp:Label>
                                    <asp:Label runat="server" ID="StatusLabel" Text='<%#Eval("IsActive")%>' Visible="false"></asp:Label>
                                </td>
                                <td>
                                    <div style="text-align: center;">
                                        <asp:LinkButton runat="server" ToolTip="Edit" ID="editLinkButton" CssClass="edit"
                                            CommandArgument='<%# DataBinder.Eval(Container.DataItem,"STT") %>' OnCommand="EditOnCommand"></asp:LinkButton>
                                        <asp:LinkButton runat="server" ToolTip="Delete" ID="deleteButton1" CssClass="delete"
                                            CommandArgument='<%# DataBinder.Eval(Container.DataItem,"UserId") %>' OnCommand="DeleteOnCommand"
                                            OnClientClick="return confirmPost()"></asp:LinkButton>
                                    </div>
                                </td>
                            </tr>
                        </AlternatingItemTemplate>
                    </asp:ListView>
                    <div class="divPage">
                        <asp:LinkButton ID="FirstPageButton" Text="First" runat="server" OnClick="FirstPageButton_Click" />
                        <asp:LinkButton ID="PreviewPageButton" Text="Preview" runat="server" OnClick="PreviewPageButton_Click" />
                        <asp:Label ID="PageLabel" runat="server" CssClass="curent"></asp:Label>
                        <asp:LinkButton ID="NextPageButton" Text="Next" runat="server" OnClick="NextPageButton_Click" />
                        <asp:LinkButton ID="LastPageButton" Text="Last" runat="server" OnClick="LastPageButton_Click" />
                    </div>
                </asp:Panel>
                <asp:Panel runat="server" ID="EditPanel">
                    <h2 class="divTitle">
                        Edit User</h2>
                    <table style="height: 100%; width: 58%; margin: 0 auto;">
                        <tr>
                            <td>
                                Role
                            </td>
                            <td>
                                <asp:DropDownList runat="server" ID="RoleDropDownList" Width="170px" />
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Username
                            </td>
                            <td>
                                <asp:TextBox runat="server" ID="UserIdTextBox" Width="166px" Visible="false"></asp:TextBox>
                                <asp:TextBox runat="server" ID="UserNameEditTextBox" Width="166px" Enabled="false"></asp:TextBox>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Status
                            </td>
                            <td>
                                <asp:DropDownList ID="StatusEditDropDownList" runat="server" Width="170px" />
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2" style="text-align: center">
                                <asp:Label runat="server" ID="MessageLabel"></asp:Label>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2" style="text-align: center">
                                <asp:Button runat="server" ID="UpdateButton" Text="Update" OnClick="UpdateButton_OnClick" />
                                <asp:Button runat="server" ID="BackButton" Text="Back" OnClick="BackButton_OnClick" />
                            </td>
                        </tr>
                    </table>
                </asp:Panel>
            </ContentTemplate>
        </asp:UpdatePanel>
    </div>
</asp:Content>
